home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  8.3 KB  |  295 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __EVENTS__
  21. #define __EVENTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __QUICKDRAW__
  30. #include <Quickdraw.h>
  31. #endif
  32. /*    #include <MixedMode.h>                                        */
  33. /*    #include <QuickdrawText.h>                                    */
  34.  
  35. #ifndef __OSUTILS__
  36. #include <OSUtils.h>
  37. #endif
  38. /*    #include <Memory.h>                                            */
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #if PRAGMA_ALIGN_SUPPORTED
  45. #pragma options align=mac68k
  46. #endif
  47.  
  48. #if PRAGMA_IMPORT_SUPPORTED
  49. #pragma import on
  50. #endif
  51.  
  52. typedef UInt16 MacOSEventKind;
  53.  
  54.  
  55. enum {
  56.     nullEvent                    = 0,
  57.     mouseDown                    = 1,
  58.     mouseUp                        = 2,
  59.     keyDown                        = 3,
  60.     keyUp                        = 4,
  61.     autoKey                        = 5,
  62.     updateEvt                    = 6,
  63.     diskEvt                        = 7,
  64.     activateEvt                    = 8,
  65.     osEvt                        = 15
  66. };
  67.  
  68. typedef UInt16 MacOSEventMask;
  69.  
  70.  
  71. enum {
  72.     mDownMask                    = 0x0002,                        /* mouse button pressed */
  73.     mUpMask                        = 0x0004,                        /* mouse button released */
  74.     keyDownMask                    = 0x0008,                        /* key pressed */
  75.     keyUpMask                    = 0x0010,                        /* key released */
  76.     autoKeyMask                    = 0x0020,                        /* key repeatedly held down */
  77.     updateMask                    = 0x0040,                        /* window needs updating */
  78.     diskMask                    = 0x0080,                        /* disk inserted */
  79.     activMask                    = 0x0100,                        /* activate/deactivate window */
  80.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents) */
  81.     osMask                        = 0x8000,                        /* operating system events (suspend, resume) */
  82.     everyEvent                    = 0xFFFF                        /* all of the above */
  83. };
  84.  
  85. enum {
  86. /* event message equates */
  87.     charCodeMask                = 0x000000FF,
  88.     keyCodeMask                    = 0x0000FF00,
  89.     adbAddrMask                    = 0x00FF0000,
  90.     osEvtMessageMask            = 0xFF000000L,
  91. /* OS event messages.  Event (sub)code is in the high byte of the message field. */
  92.     mouseMovedMessage            = 0x00FA,
  93.     suspendResumeMessage        = 0x0001,
  94.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend */
  95.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change */
  96. };
  97.  
  98. typedef UInt16 MacOSEventModifiers;
  99.  
  100.  
  101. enum {
  102. /* modifiers */
  103.     activeFlag                    = 0x0001,                        /* Bit 0 of modifiers for activateEvt and mouseDown events */
  104.     btnState                    = 0x0080,                        /* Bit 7 of low byte is mouse button state */
  105.     cmdKey                        = 0x0100,                        /* Bit 0 of high byte */
  106.     shiftKey                    = 0x0200,                        /* Bit 1 of high byte */
  107.     alphaLock                    = 0x0400,                        /* Bit 2 of high byte */
  108.     optionKey                    = 0x0800,                        /* Bit 3 of high byte */
  109.     controlKey                    = 0x1000,                        /* Bit 4 of high byte */
  110.     rightShiftKey                = 0x2000,                        /* Bit 5 of high byte */
  111.     rightOptionKey                = 0x4000,                        /* Bit 6 of high byte */
  112.     rightControlKey                = 0x8000                        /* Bit 7 of high byte */
  113. };
  114.  
  115. struct EventRecord {
  116.     MacOSEventKind                    what;
  117.     UInt32                            message;
  118.     UInt32                            when;
  119.     Point                            where;
  120.     MacOSEventModifiers                modifiers;
  121. };
  122. typedef struct EventRecord EventRecord;
  123.  
  124. typedef UInt32 KeyMap[4];
  125.  
  126. struct EvQEl {
  127.     QElemPtr                        qLink;
  128.     short                            qType;
  129.     MacOSEventKind                    evtQWhat;                    /* this part is identical to the EventRecord as... */
  130.     UInt32                            evtQMessage;                /* defined above */
  131.     UInt32                            evtQWhen;
  132.     Point                            evtQWhere;
  133.     MacOSEventModifiers                evtQModifiers;
  134. };
  135. typedef struct EvQEl EvQEl;
  136.  
  137. typedef EvQEl *EvQElPtr;
  138.  
  139. typedef void (*GetNextEventFilterProcPtr)(EventRecord *theEvent, Boolean *result);
  140.  
  141. #if GENERATINGCFM
  142. typedef UniversalProcPtr GetNextEventFilterUPP;
  143. #else
  144. typedef Register68kProcPtr GetNextEventFilterUPP;
  145. #endif
  146.  
  147. enum {
  148.     uppGetNextEventFilterProcInfo = SPECIAL_CASE_PROCINFO( kSpecialCaseGNEFilterProc )
  149. };
  150.  
  151. #if GENERATINGCFM
  152. #define NewGetNextEventFilterProc(userRoutine)        \
  153.         (GetNextEventFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  154. #else
  155. #define NewGetNextEventFilterProc(userRoutine)        \
  156.         ((GetNextEventFilterUPP) (userRoutine))
  157. #endif
  158.  
  159. #if GENERATINGCFM
  160. #define CallGetNextEventFilterProc(userRoutine, theEvent, result)        \
  161.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, (theEvent), (result))
  162. #else
  163. /* (*GetNextEventFilterProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  164. #endif
  165.  
  166. typedef GetNextEventFilterUPP GNEFilterUPP;
  167.  
  168. typedef pascal void (*FKEYProcPtr)(void);
  169.  
  170. #if GENERATINGCFM
  171. typedef UniversalProcPtr FKEYUPP;
  172. #else
  173. typedef FKEYProcPtr FKEYUPP;
  174. #endif
  175.  
  176. enum {
  177.     uppFKEYProcInfo = kPascalStackBased
  178. };
  179.  
  180. #if GENERATINGCFM
  181. #define NewFKEYProc(userRoutine)        \
  182.         (FKEYUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  183. #else
  184. #define NewFKEYProc(userRoutine)        \
  185.         ((FKEYUPP) (userRoutine))
  186. #endif
  187.  
  188. #if GENERATINGCFM
  189. #define CallFKEYProc(userRoutine)        \
  190.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFKEYProcInfo)
  191. #else
  192. #define CallFKEYProc(userRoutine)        \
  193.         (*(userRoutine))()
  194. #endif
  195.  
  196. extern pascal UInt32 GetCaretTime( void )
  197.     TWOWORDINLINE( 0x2EB8, 0x02F4 ); /* MOVE.l $02F4,(SP) */
  198. extern pascal void SetEventMask( MacOSEventMask value )
  199.     TWOWORDINLINE( 0x31DF, 0x0144 ); /* MOVE.w (SP)+,$0144 */
  200. extern pascal MacOSEventMask GetEventMask( void )
  201.     TWOWORDINLINE( 0x3EB8, 0x0144 ); /* MOVE.w $0144,(SP) */
  202. extern pascal QHdrPtr GetEvQHdr(void)
  203.  THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  204. /* InterfaceLib exports GetEvQHdr, so make GetEventQueue map to that */
  205. #define GetEventQueue() GetEvQHdr()
  206. extern pascal UInt32 GetDblTime( void )
  207.     TWOWORDINLINE( 0x2EB8, 0x02F0 ); /* MOVE.l $02F0,(SP) */
  208. /* InterfaceLib exports GetDblTime, so make GetDoubleClickTime map to that */
  209. #define GetDoubleClickTime() GetDblTime()
  210. extern pascal Boolean GetNextEvent(MacOSEventMask eventMask, EventRecord *theEvent)
  211.  ONEWORDINLINE(0xA970);
  212. extern pascal Boolean WaitNextEvent(MacOSEventMask eventMask, EventRecord *theEvent, UInt32 sleep, RgnHandle mouseRgn)
  213.  ONEWORDINLINE(0xA860);
  214. extern pascal Boolean EventAvail(MacOSEventMask eventMask, EventRecord *theEvent)
  215.  ONEWORDINLINE(0xA971);
  216. extern pascal void GetMouse(Point *mouseLoc)
  217.  ONEWORDINLINE(0xA972);
  218. extern pascal Boolean Button(void)
  219.  ONEWORDINLINE(0xA974);
  220. extern pascal Boolean StillDown(void)
  221.  ONEWORDINLINE(0xA973);
  222. extern pascal Boolean WaitMouseUp(void)
  223.  ONEWORDINLINE(0xA977);
  224. extern pascal void GetKeys(KeyMap theKeys)
  225.  ONEWORDINLINE(0xA976);
  226. extern pascal UInt32 KeyTranslate(const void *transData, UInt16 keycode, UInt32 *state)
  227.  ONEWORDINLINE(0xA9C3);
  228. extern pascal UInt32 TickCount(void)
  229.  ONEWORDINLINE(0xA975);
  230.  
  231. #if !GENERATINGCFM
  232. #pragma parameter __D0 PostEvent(__A0, __D0)
  233. #endif
  234. extern pascal OSErr PostEvent(MacOSEventKind eventNum, UInt32 eventMsg)
  235.  ONEWORDINLINE(0xA02F);
  236.  
  237. #if !GENERATINGCFM
  238. #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  239. #endif
  240. extern pascal OSErr PPostEvent(MacOSEventKind eventCode, UInt32 eventMsg, EvQElPtr *qEl)
  241.  TWOWORDINLINE(0xA12F, 0x2288);
  242.  
  243. #if !GENERATINGCFM
  244. #pragma parameter __D0 OSEventAvail(__D0, __A0)
  245. #endif
  246. extern pascal Boolean OSEventAvail(MacOSEventMask mask, EventRecord *theEvent)
  247.  TWOWORDINLINE(0xA030, 0x5240);
  248.  
  249. #if !GENERATINGCFM
  250. #pragma parameter __D0 GetOSEvent(__D0, __A0)
  251. #endif
  252. extern pascal Boolean GetOSEvent(MacOSEventMask mask, EventRecord *theEvent)
  253.  TWOWORDINLINE(0xA031, 0x5240);
  254. extern pascal void FlushEvents(MacOSEventMask whichMask, MacOSEventMask stopMask)
  255.  TWOWORDINLINE(0x201F, 0xA032);
  256. extern pascal void SystemClick(const EventRecord *theEvent, WindowPtr theWindow)
  257.  ONEWORDINLINE(0xA9B3);
  258. extern pascal void SystemTask(void)
  259.  ONEWORDINLINE(0xA9B4);
  260. extern pascal Boolean SystemEvent(const EventRecord *theEvent)
  261.  ONEWORDINLINE(0xA9B2);
  262. #if OLDROUTINENAMES
  263.  
  264. enum {
  265.     networkEvt                    = 10,
  266.     driverEvt                    = 11,
  267.     app1Evt                        = 12,
  268.     app2Evt                        = 13,
  269.     app3Evt                        = 14,
  270.     app4Evt                        = 15,
  271.     networkMask                    = 0x0400,
  272.     driverMask                    = 0x0800,
  273.     app1Mask                    = 0x1000,
  274.     app2Mask                    = 0x2000,
  275.     app3Mask                    = 0x4000,
  276.     app4Mask                    = 0x8000
  277. };
  278.  
  279. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  280. #endif
  281.  
  282. #if PRAGMA_IMPORT_SUPPORTED
  283. #pragma import off
  284. #endif
  285.  
  286. #if PRAGMA_ALIGN_SUPPORTED
  287. #pragma options align=reset
  288. #endif
  289.  
  290. #ifdef __cplusplus
  291. }
  292. #endif
  293.  
  294. #endif /* __EVENTS__ */
  295.